﻿package test {
	import extremefx.remoting.encoders.WDDX;	
	
	import flash.events.Event;	
	
	import extremefx.unitTest.Assert;	
	
	import flash.text.TextFormat;	
	import flash.text.TextField;	
	import flash.display.Sprite;	
	
	/**
	 * @author Marcelo Volmaro
	 */
	 
	[Frame(factoryClass="extremefx.Preloader")];
	public class RemotingEncodersTest extends Sprite {
		private var _tf:TextField;
		
		public function main():void{
			var tf:TextField = _tf = new TextField();
			var tfmt:TextFormat = new TextFormat("arial unicode ms", 14, 0);
			stage.addEventListener(Event.RESIZE, resizeStage);
			addChild(tf);
			tf.x = 0;
			tf.y = 0;
			tf.width = stage.stageWidth;
			tf.height = stage.stageHeight;
			tf.defaultTextFormat = tfmt;
			Assert.setOutput(tf);
			
			
			testWDDX();
		}
		
		private function testWDDX():void{
			var a:Object = {
				str:"esto es un string",
				num:10.74,
				dat:new Date(),
				arr:[1,2,3,4,5,6,7,8,9,10],
				bol:true,
				nested:{
					str:"esto es un string",
					num:10.74,
					dat:new Date(),
					arr:[1,2,3,4,5,6,7,8,9,10],
					bol:true
				}
			};
			
			var b:WDDX = new WDDX();
			var xml:String = b.serialize(a);
			_tf.appendText(xml);
			
			var c:Object = b.deserialize(xml);
			for (var i:String in c){
				trace(i+":"+c[i]);
			}
		}
		
		private function resizeStage(event:Event):void {
			_tf.width = stage.stageWidth;
			_tf.height = stage.stageHeight;
		}
	}
}
